package com.ita.acmsystem.merchant.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ita.acmsystem.merchant.entity.FoodTypes;
import com.ita.acmsystem.merchant.service.IFoodTypesService;
import com.ita.acmsystem.merchant.service.impl.FoodTypesServiceImpl;

/**
 * Servlet implementation class addFoodsContentServlet
 */
public class AddFoodsContentServlet extends HttpServlet {
	
	private static final long serialVersionUID = 1L;
	
	private IFoodTypesService foodTypesService = new FoodTypesServiceImpl();
       
	List<FoodTypes> foodTypesList;
	
    /**
     * @see HttpServlet#HttpServlet()
     */
    public AddFoodsContentServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		AddFoodsContent(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		AddFoodsContent(request, response);
	}

	private void AddFoodsContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if(foodTypesList == null)
			foodTypesList = foodTypesService.getAllFoodTypes();
		request.setAttribute("foodTypesList", foodTypesList);
		request.getRequestDispatcher("add.jsp").forward(request, response);
	}

}
